package http请求;

import java.io.UnsupportedEncodingException;

/**
 * @author yangjicong
 * @date 2022/2/7
 */
public class RunHttp {
	public static void main(String[] args) {
		/*知识点一:
		* 网络请求前可以进行手动编码
		*
		* */
		 //String url ="https://mapi.bestpay.com.cn/gapi//o2o/nearby/service/merchantDetails";
		 //url = new String(url.getBytes("iso8859-1"),"UTF-8");
		 //System.out.println("url = " + url);

		httpTest();




	}

	/**
	 * 调用工具类进行网络请求
	 */
	public static void httpTest()  {
		//可以通过网页查看编码方式
		String url ="https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=%E6%B3%95%E5%AE%9A%E8%8A%82%E5%81%87%E6%97%A5&co=&resource_id=39042&t=1617089118959&ie=utf8&oe=gbk&cb=op_aladdin_callback&format=json&tn=wisetpl&cb=jQuery110203576901702188473_1617089118772&_=1617089118773";
		//http请求示例
		String result = HttpClientUtil.get(url);

		System.out.println("result = " + result);

/*		//可以对结果编码   ISO-8859-1; GB2312
		String s = null;
		try {
			s = new String(result.getBytes("GBK"), "GBK");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}*/



	}

}
